#include "DoorTrigger.h"
#include "Level.h"
#include "Camera.h"

#define EFFECT_DURATION 250

//----------------------
// public declarations
//----------------------

void DoorTrigger::hit(const SimpleDirection dir, BaseUnit* player, CRstring parameter)
{
    Hero* hero = (Hero*)player;
    // make sure up is pressed and hero is not in air
    if (hero->getLevel()->GetInput()->isUp() && not hero->m_collisionInfo.isInAir(hero->getPosition()))
    {
        // zoom in on the door
        EFFECTS->zoomIn(EFFECT_DURATION,getScreenCenter(),m_size);
        // pause the game logic for the time of the effect
        getLevel()->logicPause(EFFECT_DURATION);
        // Reset movement
        player->stopRightThere();
        player->getLevel()->GetInput()->resetUp();
        // teleport the player
        TeleportTrigger::hit(dir,player,"noEffect");
        // zoom out of the door
        EFFECTS->zoomOut(EFFECT_DURATION,player->getCenter() - CAMERA->getMapOffset(),m_size);
        getLevel()->logicPause(EFFECT_DURATION);
    }
}

//----------------------
// private declarations
//----------------------

void DoorTrigger::customUpdate()
{

}
